/*************************************************
Author: byron 
Date: 12/07/2013
Description:
Notes:
*************************************************/

#ifndef __CRewardBackMgr_h__
#define __CRewardBackMgr_h__

#include "commclass.h"

class MsgReqGMPlayer;
class MsgAnsGMPlayer;
class MsgReqRewardBack;
class MsgAnsRewardBack;
class CPlayerOnlineData;

class CRewardBackMgr
{
public:
    enum CMD_REWARD_BACK_SUB_TAG
    {
        CMD_REWARD_BACK_SUB_GET_INFO = 1,      //获取信息
        CMD_REWARD_BACK_SUB_FREE_BACK = 2,     //免费找回
        CMD_REWARD_BACK_SUB_GOLD_BACK = 3,     //符石找回
    };

    enum ENM_REWARD_BACK_MACRO_TAG
    {
        ENM_REWARD_BACK_STAT_LOGIN = 1, //更新类型 -- 登录时候
        ENM_REWARD_BACK_STAT_LEVEL = 2, //更新类型 -- 升级时候
        ENM_REWARD_BACK_OPEN_LEVEL = 14,//达到特定等级之后触发

        ENM_REWARD_BACK_BIT_WORLD_BOSS_ONE = (0x1<<0),  //世界BOSS第一场
        ENM_REWARD_BACK_BIT_WORLD_BOSS_TWO = (0x1<<1),  //世界BOSS第二场
        ENM_REWARD_BACK_BIT_ACADEMY_BOSS = (0x1<<2),    //学院BOSS
        ENM_REWARD_BACK_BIT_ENEMY_ATK_CITY = (0x1<<3),  //怪物攻城

        ENM_REWARD_BACK_COST_ITEM_ID = 209, //符石替代道具ID -- 时光转换器
        ENM_REWARD_BACK_GOLD_EACH_TIMES = 10, //符石找回时每次消耗的符石数量
    };

    CRewardBackMgr()
    {
    }

    virtual ~CRewardBackMgr()
    {
    }

    void UpdateOpenZeroTime(CPlayerBaseInfo& stPlayerBase,
            CPlayerDetailInfoEx1& stPlayerDetailEx1, int iUpdateStat);

    void UpdateDetailToDB(CPlayerDetailInfo& stPlayerDetail);

    void UpdateDetailEx1ToDB(CPlayerDetailInfoEx1& stPlayerDetailEx1);

    void UpdateZoneDataToDB();

    bool IsTargetAct(int iActID);

    void SetActOpen(int iActID, int iWorldLevel);

    void SetActOpen(CRewardBackUnit& stUnit, int iActID, int iActEndTime,
            int iWorldLevel, bool& bUpdateDB);

    void SetPlayerAct(unsigned int uiGID, int iActID);

    void SetPlayerAct(CPlayerDetailInfoEx1& stPlayerDetailEx1, int iActID);

    void SetPlayerAct(CPlayerRewardBackUnit& stUnit, int iActID,
            bool& bUpdateDB);

    void GetUnActList(CPlayerBaseInfo& stPlayerBase,
            CPlayerDetailInfoEx1& stPlayerDetailEx1, int iActID,
            T_REWARD_BACK_LIST& stLevelList);

    void GetRewardValue(int iActID, int& iExp, int& iRepu, int& iSilver,
            T_REWARD_BACK_LIST& stLevelList);

    int CalcExp(short& shLevel, int64& i64RoleExp, int64 i64AddExp,
            int64& i64LevelExp);

    int GetInfo(CPlayerBaseInfo& stPlayerBase,
            CPlayerDetailInfoEx1& stPlayerDetailEx1, MsgAnsRewardBack& stAns);

    void SendReward(unsigned int uiGID, int iExp, int iRepu, int iSilver);

    int FreeBack(CPlayerBaseInfo& stPlayerBase,
            CPlayerDetailInfoEx1& stPlayerDetailEx1, MsgAnsRewardBack& stAns);

    int GoldBack(CPlayerBaseInfo& stPlayerBase,
        CPlayerDetailInfo& stPlayerDetail,
        CPlayerDetailInfoEx1& stPlayerDetailEx1,
        CPlayerOnlineData& stPlayerOnline, MsgAnsRewardBack& stAns);

    int GMDeal(CPlayerBaseInfo& stPlayerBase, 
            CPlayerDetailInfoEx1& stPlayerDetailEx1, MsgReqGMPlayer& stReq,
            MsgAnsGMPlayer& stAns);
};

#endif //__CRewardBackMgr_h__

